#include "mydialog.h"

MyDialog::MyDialog(QObject *parent) : QObject(parent)
{

}




void MyDialog::createdTimeDialog(QWidget *widget,CustomSlider* slider)
{
    QDialog *timeDialog = new QDialog(widget);
    timeDialog->setFixedSize(500,100);
    timeDialog->setWindowTitle("检测时间设置");
    Qt::WindowFlags flags = Qt::Dialog;
    flags |= Qt::WindowCloseButtonHint;
    timeDialog->setWindowFlags(flags);
    timeDialog->setStyleSheet(QString::fromUtf8("font:15px\"Time New Roman\";"));


    QPushButton *timeYesButton = new QPushButton(timeDialog);
     timeYesButton->setFixedSize(80,30);
     timeYesButton->setText("确定");
     timeYesButton->move(290,35);

     QPushButton *timeCloseButton = new QPushButton(timeDialog);
      timeCloseButton->setFixedSize(80,30);
      timeCloseButton->setText("取消");
      timeCloseButton->move(380,35);

     QLineEdit *timeLine = new QLineEdit(timeDialog);
     timeLine->setFixedSize(100,30);
     timeLine->move(140,35);
     timeLine->setText(QString::number(detectionTime));

     QLabel *timeLabel = new QLabel(timeDialog);
     timeLabel->setText("检测时间:");
     timeLabel->setFixedSize(80,80);
     timeLabel->move(40,10);

     QLabel *timeLabels = new QLabel(timeDialog);
     timeLabels->setText("秒");
     timeLabels->setFixedSize(50,80);
     timeLabels->move(250,10);

     connect(timeYesButton,&QPushButton::clicked,timeLine,[=]() mutable{
         detectionTime = timeLine->text().toDouble();
         qDebug()<<"设置检测时间："<<detectionTime<<"s";
         slider->setRange(0,detectionTime);
         delete timeLabel;
         delete timeLabels;
         delete timeLine;
         delete timeCloseButton;
         delete timeYesButton;
         timeDialog->close();
         delete timeDialog;
     });

     connect(timeCloseButton,&QPushButton::clicked,timeDialog,[=](){
         delete timeLabel;
         delete timeLabels;
         delete timeLine;
         delete timeCloseButton;
         delete timeYesButton;
         timeDialog->close();
         delete timeDialog;
     });
     timeDialog->exec();
}

QSimpleLed* MyDialog::createdStatusLamp(QSimpleLed* led)
{
    QSimpleLed *LedLamp = new QSimpleLed(led, QSimpleLed::GREEN);
    LedLamp->setFixedSize(24,24);
    LedLamp->move(1,1);
    LedLamp->setStates(QSimpleLed::OFF);
    led = LedLamp;
    return led;
    delete LedLamp;
}

void MyDialog::createdQuaternionDialog(QWidget* widget)
{

    QDialog *quaternionDialog = new QDialog(widget);
    quaternionDialog->setFixedSize(1000,800);
    quaternionDialog->setWindowTitle("四元数示例展示");
    Qt::WindowFlags flags = Qt::Dialog;
    flags |= Qt::WindowCloseButtonHint;
    quaternionDialog->setWindowFlags(flags);

    QPushButton *QYesButton = new QPushButton(quaternionDialog);
    QYesButton->setFixedSize(80,30);
    QYesButton->setText("确定");
    QYesButton->move(900,700);

    QPushButton *QCloseButton = new QPushButton(quaternionDialog);
    QCloseButton->setFixedSize(80,30);
    QCloseButton->setText("取消");
    QCloseButton->move(900,750);

    QWidget *quaternionWidget = new QWidget(quaternionDialog);
    quaternionWidget->setFixedSize(900,700);
    quaternionWidget->move(0,0);


    QLineEdit *QLine = new QLineEdit(quaternionDialog);
    QLine->setFixedSize(150,30);
    QLine->move(140,35);
    QLine->setText("40,20,20,10");



     connect(QYesButton,&QPushButton::clicked,quaternionDialog,[=]() mutable{


         delete QCloseButton;
         delete QYesButton;
         quaternionDialog->close();
         delete quaternionDialog;
     });

     connect(QCloseButton,&QPushButton::clicked,quaternionDialog,[=](){

         delete QCloseButton;
         delete QYesButton;
         quaternionDialog->close();
         delete quaternionDialog;
     });
     quaternionDialog->exec();
}

void MyDialog::createdUploadFile(QWidget* widget)
{
    QDialog *uploadFileDialog = new QDialog(widget);
    uploadFileDialog->setFixedSize(400,120);
    uploadFileDialog->setWindowTitle("上传文件");
    Qt::WindowFlags flags = Qt::Dialog;
    flags |= Qt::WindowCloseButtonHint;
    uploadFileDialog->setWindowFlags(flags);

    QPushButton *uploadFileYesButton = new QPushButton(uploadFileDialog);
    uploadFileYesButton->setFixedSize(80,30);
    uploadFileYesButton->setText("确定");
    uploadFileYesButton->move(300,10);

    QPushButton *uploadFileCloseButton = new QPushButton(uploadFileDialog);
    uploadFileCloseButton->setFixedSize(80,30);
    uploadFileCloseButton->setText("取消");
    uploadFileCloseButton->move(300,70);

    QRadioButton *uploadFileRadioButton1 = new QRadioButton(uploadFileDialog);
    uploadFileRadioButton1->setText("只打印步态PDF");
    uploadFileRadioButton1->move(50,10);
    QRadioButton *uploadFileRadioButton2 = new QRadioButton(uploadFileDialog);
    uploadFileRadioButton2->setText("只打印平衡PDF");
    uploadFileRadioButton2->move(50,40);
    QRadioButton *uploadFileRadioButton3 = new QRadioButton(uploadFileDialog);
    uploadFileRadioButton3->setText("两个PDF都要打印");
    uploadFileRadioButton3->move(50,70);


    connect(uploadFileRadioButton1,&QRadioButton::clicked,this,[=]() mutable{
        printContentChoose = 1;
        qDebug()<<"printContentChoose:"<<printContentChoose;
    });
    connect(uploadFileRadioButton2,&QRadioButton::clicked,this,[=]() mutable{
        printContentChoose = 2;
        qDebug()<<"printContentChoose:"<<printContentChoose;
    });
    connect(uploadFileRadioButton3,&QRadioButton::clicked,this,[=]() mutable{
        printContentChoose = 3;
        qDebug()<<"printContentChoose:"<<printContentChoose;
    });


     connect(uploadFileYesButton,&QPushButton::clicked,uploadFileDialog,[=]() mutable{

         QSettings settings("floderContent.ini",QSettings::IniFormat);
         settings.beginGroup("section");
         settings.setValue("printContentChoose",printContentChoose);
         work_floder = tr("D:\\masterWorkProject\\test\\111");
         save_floder = tr("D:\\masterWorkProject\\test\\1");
         settings.setValue("work_floder",work_floder);
         settings.setValue("save_floder",save_floder);
         settings.endGroup();
         uploadFileDialog->close();
         uploadFile.upload();
         delete uploadFileCloseButton;
         delete uploadFileYesButton;
         delete uploadFileRadioButton1;
         delete uploadFileRadioButton2;
         delete uploadFileRadioButton3;

         delete uploadFileDialog;
     });

     connect(uploadFileCloseButton,&QPushButton::clicked,uploadFileDialog,[=](){

         delete uploadFileCloseButton;
         delete uploadFileYesButton;
         delete uploadFileRadioButton1;
         delete uploadFileRadioButton2;
         delete uploadFileRadioButton3;
         uploadFileDialog->close();
         delete uploadFileDialog;
     });
     uploadFileDialog->exec();
}





void MyDialog::createdThreeFuctionDialog(QWidget* widget,double* number)
{

    QDialog *threeFuctionDialog = new QDialog(widget);
    threeFuctionDialog->setFixedSize(700,1080);
    threeFuctionDialog->setWindowTitle("三大检测模块");
    Qt::WindowFlags flags = Qt::Dialog;
    flags |= Qt::WindowCloseButtonHint;
    threeFuctionDialog->setWindowFlags(flags);
    threeFuctionDialog->setStyleSheet(QString::fromUtf8("font:15px\"Time New Roman\";"));

    QPushButton *gaitButton = new QPushButton(threeFuctionDialog);
    gaitButton->setFixedSize(500,280);
    gaitButton->setText("步态检测");
    gaitButton->move(100,100);

    QPushButton *standingButton = new QPushButton(threeFuctionDialog);
    standingButton->setFixedSize(500,280);
    standingButton->setText("静态站立检测");
    standingButton->move(100,400);

    QPushButton *instantaneousButton = new QPushButton(threeFuctionDialog);
    instantaneousButton->setFixedSize(500,280);
    instantaneousButton->setText("瞬时检测");
    instantaneousButton->move(100,700);


     connect(gaitButton,&QPushButton::clicked,threeFuctionDialog,[=]() mutable{
    //进入步态检测（自定义时间）

         delete standingButton;
         delete gaitButton;
         delete instantaneousButton;
         threeFuctionDialog->close();
         delete threeFuctionDialog;
         createdGaitSubmodeDialog(widget);
         *number =  detectionTime;
     });
     connect(standingButton,&QPushButton::clicked,threeFuctionDialog,[=]()mutable{
    //进入静态站立（自定义时间）

         delete standingButton;
         delete gaitButton;
         delete instantaneousButton;
         threeFuctionDialog->close();
         delete threeFuctionDialog;
         createdStandSubmodeDialog(widget);
         *number =  detectionTime;
     });

     connect(instantaneousButton,&QPushButton::clicked,threeFuctionDialog,[=]()mutable{
    //瞬时检测（固定时间  例 0.365s）
//         createdUserInfo(widget);
        modeCheck.append(instantaneousButton->text());
         delete standingButton;
         delete gaitButton;
         delete instantaneousButton;
         threeFuctionDialog->close();
         delete threeFuctionDialog;
         createdInstantaneousDialog(widget);
         *number =  detectionTime;
     });
     threeFuctionDialog->exec();
}
QStringList modeCheck;//声明数组

void MyDialog::createdStandSubmodeDialog(QWidget* widget)
{
    QDialog *StandSubmodeDialog = new QDialog(widget);
    StandSubmodeDialog->setFixedSize(1200,350);
    StandSubmodeDialog->setWindowTitle("静态站立多模式选择");
    Qt::WindowFlags flags = Qt::Dialog;
    flags |= Qt::WindowCloseButtonHint;
    StandSubmodeDialog->setWindowFlags(flags);
    StandSubmodeDialog->setStyleSheet(QString::fromUtf8("font:15px\"Time New Roman\";"));

    QPushButton *timeYesButton = new QPushButton(StandSubmodeDialog);
     timeYesButton->setFixedSize(80,30);
     timeYesButton->setText("确定");
     timeYesButton->adjustSize();
     timeYesButton->move(820,310);

     QPushButton *timeCloseButton = new QPushButton(StandSubmodeDialog);
      timeCloseButton->setFixedSize(80,30);
      timeCloseButton->setText("取消");
      timeCloseButton->adjustSize();
      timeCloseButton->move(910,310);

     QLineEdit *timeLine = new QLineEdit(StandSubmodeDialog);
     timeLine->setFixedSize(100,30);
     timeLine->move(690,310);
     timeLine->setText(QString::number(detectionTime));

     QLabel *timeLabel = new QLabel(StandSubmodeDialog);
     timeLabel->setText("检测时间:");
     timeLabel->adjustSize();
//     timeLabel->setFixedSize(60,30);
     timeLabel->move(600,310);

     QLabel *timeLabels = new QLabel(StandSubmodeDialog);
     timeLabels->setText("秒");
     timeLabels->adjustSize();
     timeLabels->setFixedSize(30,30);
     timeLabels->move(800,310);

     QLabel *timeLabelGait = new QLabel(StandSubmodeDialog);
     timeLabelGait->setText("静态站立检测模式选择");
     timeLabelGait->adjustSize();
     timeLabelGait->move(440,10);

     QCheckBox *doubleAndOpenCheckBox = new QCheckBox(StandSubmodeDialog);
     doubleAndOpenCheckBox->setText("双足战立睁眼模式");
     doubleAndOpenCheckBox->adjustSize();
     doubleAndOpenCheckBox->move(50,120);

     QCheckBox *doubleAndCloseCheckBox = new QCheckBox(StandSubmodeDialog);
     doubleAndCloseCheckBox->setText("双足战立闭眼模式");
     doubleAndCloseCheckBox->adjustSize();
     doubleAndCloseCheckBox->move(50,190);

     QCheckBox *singleAndOpenLeftCheckBox = new QCheckBox(StandSubmodeDialog);
     singleAndOpenLeftCheckBox->setText("单足战立睁眼模式(左)");
     singleAndOpenLeftCheckBox->adjustSize();
     singleAndOpenLeftCheckBox->move(430,120);

     QCheckBox *singleAndOpenRightCheckBox = new QCheckBox(StandSubmodeDialog);
     singleAndOpenRightCheckBox->setText("单足战立睁眼模式(右)");
     singleAndOpenRightCheckBox->adjustSize();
     singleAndOpenRightCheckBox->move(430,190);

     QCheckBox *singleAndCloseLeftCheckBox = new QCheckBox(StandSubmodeDialog);
     singleAndCloseLeftCheckBox->setText("单足站立闭眼模式(左)");
     singleAndCloseLeftCheckBox->adjustSize();
     singleAndCloseLeftCheckBox->move(810,120);

     QCheckBox *singleAndRightLeftCheckBox = new QCheckBox(StandSubmodeDialog);
     singleAndRightLeftCheckBox->setText("单足站立闭眼模式(右)");
     singleAndRightLeftCheckBox->adjustSize();
     singleAndRightLeftCheckBox->move(810,190);

     connect(doubleAndOpenCheckBox,&QCheckBox::stateChanged,StandSubmodeDialog,[=](){
         if(doubleAndOpenCheckBox->isChecked()){
             modeCheck.append(doubleAndOpenCheckBox->text());
         }
         else{
             foreach(QString variable,modeCheck){
                 modeCheck.removeOne(doubleAndOpenCheckBox->text());
             }
         }
     });

     connect(doubleAndCloseCheckBox,&QCheckBox::stateChanged,StandSubmodeDialog,[=](){
         if(doubleAndCloseCheckBox->isChecked()){
                 modeCheck.append(doubleAndCloseCheckBox->text());
         }
         else{
             foreach(QString variable,modeCheck){
                 modeCheck.removeOne(doubleAndCloseCheckBox->text());
             }
         }
     });

     connect(singleAndOpenLeftCheckBox,&QCheckBox::stateChanged,StandSubmodeDialog,[=](){
         if(singleAndOpenLeftCheckBox->isChecked()){
                 modeCheck.append(singleAndOpenLeftCheckBox->text());
         }
         else{
             foreach(QString variable,modeCheck){
                 modeCheck.removeOne(singleAndOpenLeftCheckBox->text());
             }
         }
     });

     connect(singleAndOpenRightCheckBox,&QCheckBox::stateChanged,StandSubmodeDialog,[=](){
         if(singleAndOpenRightCheckBox->isChecked()){
                 modeCheck.append(singleAndOpenRightCheckBox->text());
         }
         else{
             foreach(QString variable,modeCheck){
                 modeCheck.removeOne(singleAndOpenRightCheckBox->text());
             }
         }
     });

     connect(singleAndCloseLeftCheckBox,&QCheckBox::stateChanged,StandSubmodeDialog,[=](){
         if(singleAndCloseLeftCheckBox->isChecked()){
                 modeCheck.append(singleAndCloseLeftCheckBox->text());
         }
         else{
             foreach(QString variable,modeCheck){
                 modeCheck.removeOne(singleAndCloseLeftCheckBox->text());
             }
         }
     });

     connect(singleAndRightLeftCheckBox,&QCheckBox::stateChanged,StandSubmodeDialog,[=](){
         if(singleAndRightLeftCheckBox->isChecked()){
                 modeCheck.append(singleAndRightLeftCheckBox->text());
         }
         else{
             foreach(QString variable,modeCheck){
                 modeCheck.removeOne(singleAndRightLeftCheckBox->text());
             }
         }
     });

     connect(timeYesButton,&QPushButton::clicked,timeLine,[=]() mutable{
         detectionTime = timeLine->text().toDouble();
         qDebug()<<"设置检测时间："<<detectionTime<<"s"<<" modeCheck:"<<modeCheck.size();
         if(modeCheck.size()==0||modeCheck.isEmpty()){
             createNoModeChoose(widget);
         }
         else{
            delete timeLabel;
            delete timeLabels;
            delete timeLine;
            delete timeCloseButton;
            delete timeYesButton;
            StandSubmodeDialog->close();
            delete StandSubmodeDialog;
         }
     });
     connect(timeCloseButton,&QPushButton::clicked,StandSubmodeDialog,[=](){
         delete timeLabel;
         delete timeLabels;
         delete timeLine;
         delete timeCloseButton;
         delete timeYesButton;
         StandSubmodeDialog->close();
         delete StandSubmodeDialog;
     });
     StandSubmodeDialog->exec();
}

void MyDialog::createdGaitSubmodeDialog(QWidget* widget)
{

    QDialog *GaitSubmodeDialog = new QDialog(widget);
    GaitSubmodeDialog->setFixedSize(1000,350);
    GaitSubmodeDialog->setWindowTitle("步态多模式选择");
    Qt::WindowFlags flags = Qt::Dialog;
    flags |= Qt::WindowCloseButtonHint;
    GaitSubmodeDialog->setWindowFlags(flags);
    GaitSubmodeDialog->setStyleSheet(QString::fromUtf8("font:15px\"Time New Roman\";"));


    QPushButton *timeYesButton = new QPushButton(GaitSubmodeDialog);
     timeYesButton->setFixedSize(80,30);
     timeYesButton->setText("确定");
     timeYesButton->move(820,310);

     QPushButton *timeCloseButton = new QPushButton(GaitSubmodeDialog);
      timeCloseButton->setFixedSize(80,30);
      timeCloseButton->setText("取消");
      timeCloseButton->move(910,310);

     QLineEdit *timeLine = new QLineEdit(GaitSubmodeDialog);
     timeLine->setFixedSize(100,30);
     timeLine->move(690,310);
     timeLine->setText(QString::number(detectionTime));

     QLabel *timeLabel = new QLabel(GaitSubmodeDialog);
     timeLabel->setText("检测时间:");
     timeLabel->adjustSize();
     timeLabel->move(600,310);

     QLabel *timeLabels = new QLabel(GaitSubmodeDialog);
     timeLabels->setText("秒");
     timeLabels->adjustSize();
     timeLabels->move(800,310);

     QLabel *timeLabelGait = new QLabel(GaitSubmodeDialog);
     timeLabelGait->setText("步态检测模式选择");
     timeLabelGait->adjustSize();
     timeLabelGait->move(440,10);

     QCheckBox *treadmillCheckBox = new QCheckBox(GaitSubmodeDialog);
     treadmillCheckBox->setText("跑步机模式");
     treadmillCheckBox->adjustSize();
     treadmillCheckBox->move(100,120);

     QCheckBox *upslopeCheckBox = new QCheckBox(GaitSubmodeDialog);
     upslopeCheckBox->setText("上坡模式");
     upslopeCheckBox->adjustSize();
     upslopeCheckBox->move(460,120);

     QCheckBox *downslopeCheckBox = new QCheckBox(GaitSubmodeDialog);
     downslopeCheckBox->setText("下坡模式");
     downslopeCheckBox->adjustSize();
     downslopeCheckBox->move(280,190);

     QCheckBox *atsCheckBox = new QCheckBox(GaitSubmodeDialog);
     atsCheckBox->setText("上楼梯模式");
     atsCheckBox->adjustSize();
     atsCheckBox->move(820,120);

     QCheckBox *dtsCheckBox = new QCheckBox(GaitSubmodeDialog);
     dtsCheckBox->setText("下楼梯模式");
     dtsCheckBox->adjustSize();
     dtsCheckBox->move(640,190);


     connect(treadmillCheckBox,&QCheckBox::stateChanged,GaitSubmodeDialog,[=](){
         if(treadmillCheckBox->isChecked()){
             modeCheck.append(treadmillCheckBox->text());
         }
         else{
             foreach(QString variable,modeCheck){
                 modeCheck.removeOne(treadmillCheckBox->text());
             }
         }
     });

     connect(upslopeCheckBox,&QCheckBox::stateChanged,GaitSubmodeDialog,[=](){
         if(upslopeCheckBox->isChecked()){
                 modeCheck.append(upslopeCheckBox->text());
         }
         else{
             foreach(QString variable,modeCheck){
                 modeCheck.removeOne(upslopeCheckBox->text());
             }
         }
     });

     connect(downslopeCheckBox,&QCheckBox::stateChanged,GaitSubmodeDialog,[=](){
         if(downslopeCheckBox->isChecked()){
                 modeCheck.append(downslopeCheckBox->text());
         }
         else{
             foreach(QString variable,modeCheck){
                 modeCheck.removeOne(downslopeCheckBox->text());
             }
         }
     });

     connect(atsCheckBox,&QCheckBox::stateChanged,GaitSubmodeDialog,[=](){
         if(atsCheckBox->isChecked()){
                 modeCheck.append(atsCheckBox->text());
         }
         else{
             foreach(QString variable,modeCheck){
                 modeCheck.removeOne(atsCheckBox->text());
             }
         }
     });

     connect(dtsCheckBox,&QCheckBox::stateChanged,GaitSubmodeDialog,[=](){
         if(dtsCheckBox->isChecked()){
                 modeCheck.append(dtsCheckBox->text());
         }
         else{
             foreach(QString variable,modeCheck){
                 modeCheck.removeOne(dtsCheckBox->text());
             }
         }
     });

     connect(timeYesButton,&QPushButton::clicked,timeLine,[=]() mutable{
         detectionTime = timeLine->text().toDouble();
         qDebug()<<"设置检测时间："<<detectionTime<<"s modeCheck:"<<modeCheck.size();
         if(modeCheck.size()==0||modeCheck.isEmpty()){
             createNoModeChoose(widget);
         }
         else{
            delete timeLabel;
            delete timeLabels;
            delete timeLine;
            delete timeCloseButton;
            delete timeYesButton;
            GaitSubmodeDialog->close();
            delete GaitSubmodeDialog;
         }
     });

     connect(timeCloseButton,&QPushButton::clicked,GaitSubmodeDialog,[=](){

         delete timeLabel;
         delete timeLabels;
         delete timeLine;
         delete timeCloseButton;
         delete timeYesButton;
         GaitSubmodeDialog->close();
         delete GaitSubmodeDialog;

     });

     GaitSubmodeDialog->exec();
}
void MyDialog::createdInstantaneousDialog(QWidget *widget)
{    QDialog *InstantaneousDialog = new QDialog(widget);
     InstantaneousDialog->setFixedSize(350,150);
     InstantaneousDialog->setWindowTitle("步态多模式选择");
     Qt::WindowFlags flags = Qt::Dialog;
     flags |= Qt::WindowCloseButtonHint;
     InstantaneousDialog->setWindowFlags(flags);
     InstantaneousDialog->setStyleSheet(QString::fromUtf8("font:15px\"Time New Roman\";"));

     QPushButton *timeYesButton = new QPushButton(InstantaneousDialog);
      timeYesButton->setFixedSize(80,30);
      timeYesButton->setText("确定");
      timeYesButton->move(170,110);

      QPushButton *timeCloseButton = new QPushButton(InstantaneousDialog);
       timeCloseButton->setFixedSize(80,30);
       timeCloseButton->setText("取消");
       timeCloseButton->move(260,110);

      QLineEdit *timeLine = new QLineEdit(InstantaneousDialog);
      timeLine->setFixedSize(100,30);
      timeLine->move(InstantaneousDialog->width()/2-20,InstantaneousDialog->height()/2-25);
      timeLine->setText(QString::number(detectionTime));

      QLabel *timeLabel = new QLabel(InstantaneousDialog);
      timeLabel->setText("检测时间:");
      timeLabel->adjustSize();
      timeLabel->move(InstantaneousDialog->width()/2-120,InstantaneousDialog->height()/2-20);

      QLabel *timeLabels = new QLabel(InstantaneousDialog);
      timeLabels->setText("秒");
      timeLabels->adjustSize();
      timeLabels->move(InstantaneousDialog->width()/2+80,InstantaneousDialog->height()/2-20);
       connect(timeYesButton,&QPushButton::clicked,timeLine,[=]() mutable{
           detectionTime = timeLine->text().toDouble();
              delete timeLabel;
              delete timeLabels;
              delete timeLine;
              delete timeCloseButton;
              delete timeYesButton;
              InstantaneousDialog->close();
              delete InstantaneousDialog;

       });

       connect(timeCloseButton,&QPushButton::clicked,InstantaneousDialog,[=](){
           delete timeLabel;
           delete timeLabels;
           delete timeLine;
           delete timeCloseButton;
           delete timeYesButton;
           InstantaneousDialog->close();
           delete InstantaneousDialog;

       });

       InstantaneousDialog->exec();

}

void MyDialog::createCurrentModeShow(QWidget* widget, QString currentMode ){
    QDialog *ModeShow = new QDialog(widget);
    ModeShow->setFixedSize(350,150);
    ModeShow->setWindowTitle("当前所处模式提示框");
    Qt::WindowFlags flags = Qt::Dialog;
    flags |= Qt::WindowCloseButtonHint;
    ModeShow->setWindowFlags(flags);
    ModeShow->setStyleSheet(QString::fromUtf8("font:15px\"Time New Roman\";"));


    QPushButton *modeYesButton = new QPushButton(ModeShow);
     modeYesButton->setFixedSize(120,30);
     modeYesButton->setText("开始测试");
     modeYesButton->move(10,115);

     QPushButton *modeCloseButton = new QPushButton(ModeShow);
      modeCloseButton->setFixedSize(80,30);
      modeCloseButton->setText("取消");
      modeCloseButton->move(260,115);

     QLabel *modeLabel = new QLabel(ModeShow);
      modeLabel->setFixedSize(300,20);
      modeLabel->setAlignment(Qt::AlignCenter);
      modeLabel->move((ModeShow->width()-modeLabel->width())/2,35);
      modeLabel->setText(/*modeCheck.at(0)*/currentMode + "测试即将开始");

     connect(modeYesButton,&QPushButton::clicked,ModeShow,[=](){
            delete modeLabel;
            delete modeCloseButton;
            delete modeYesButton;
            ModeShow->close();
            delete ModeShow;
      });

     connect(modeCloseButton,&QPushButton::clicked,ModeShow,[=](){
           delete modeLabel;
           delete modeCloseButton;
           delete modeYesButton;
           ModeShow->close();
           delete ModeShow;
      });

    ModeShow->exec();
}
void MyDialog::createFinishTest(QWidget *widget,double *time,double *detectionTime){
    QDialog *Finish = new QDialog(widget);
    Finish->setFixedSize(350,150);
    Finish->setWindowTitle("当前所处模式提示框");
    Qt::WindowFlags flags = Qt::Dialog;
    flags |= Qt::WindowCloseButtonHint;
    Finish->setWindowFlags(flags);
    Finish->setStyleSheet(QString::fromUtf8("font:15px\"Time New Roman\";"));

    QLabel *modeLabel = new QLabel(Finish);
    modeLabel->setFixedSize(300,80);
    modeLabel->move(125,35);
    modeLabel->setText("所有测试已完成");
    //此处也可添加结束测试信号，或者在timebegin中添加=======================================================================================

    QPushButton *modeYesButton = new QPushButton(Finish);
     modeYesButton->setFixedSize(80,30);
     modeYesButton->setText("转至首页");
     modeYesButton->move(Finish->width()/2-40,115);

//     QPushButton *modeCloseButton = new QPushButton(Finish);
//      modeCloseButton->setFixedSize(80,30);
//      modeCloseButton->setText("下一项");
//      modeCloseButton->move(260,115);

      connect(modeYesButton,&QPushButton::clicked,Finish,[=]()mutable {
             delete modeLabel;
//             delete modeCloseButton;
             delete modeYesButton;
             Finish->close();
             delete Finish;
             widget->hide();

             time = 0;
             createdThreeFuctionDialog(widget,detectionTime);

             widget->show();
       });

    Finish->exec();
}
void MyDialog::createNoModeChoose(QWidget *widget){
    QDialog *noModeChoose = new QDialog(widget);
    noModeChoose->setFixedSize(350,150);
    noModeChoose->setWindowTitle("提示框");
    Qt::WindowFlags flags = Qt::Dialog;
    flags |= Qt::WindowCloseButtonHint;
    noModeChoose->setWindowFlags(flags);
    noModeChoose->setStyleSheet(QString::fromUtf8("font:15px\"Time New Roman\";"));

    QLabel *notice = new QLabel(noModeChoose);
    notice->setFixedSize(100,80);
    notice->move(125,35);
    notice->setText("模式未识别");

    QPushButton *modeChooseButton = new QPushButton(noModeChoose);
     modeChooseButton->setFixedSize(100,30);
     modeChooseButton->setText("重选模式");
     modeChooseButton->move(250,110);

    connect(modeChooseButton,&QPushButton::clicked,noModeChoose,[=](){
        delete notice;
        delete modeChooseButton;

//        noModeChoose->close();  //这里不需要先关闭线程再清除对话框，直接删除对话框即可，否则会报错
        delete noModeChoose;
    });

    noModeChoose->exec();
}

void MyDialog::createdUserInfo(QWidget* widget)
{
    userInfo = new UserInfo(widget);
    userInfo->move((QApplication::desktop()->width() - userInfo->width())/2,(QApplication::desktop()->height() - userInfo->height())/2);
    userInfo->show();

    connect(userInfo,SIGNAL(sendUserInfo(QJsonObject)),widget,SLOT(searchUserInfo(QJsonObject)));

}

void MyDialog::createdModBusTcpDialog(QWidget* widget)
{
    ipConfigure = new ModbusTcpDialog();
    ipConfigure->move ((QApplication::desktop()->width() - ipConfigure->width())/2,(QApplication::desktop()->height() - ipConfigure->height())/2);
    ipConfigure->show();
}


void MyDialog::initCustomPlot(QWidget* widget,QWidget* tab,QTreeWidget *tree,QList<QCustomPlot*> plotList){
    QVBoxLayout *FootVerticalLayout = new QVBoxLayout(widget);
    for(int i = 0 ; i < 5 ; i++){
        plotList.at(i)->setGeometry(QRect(0,widget->height()*i/6+10*(i+1),(widget->width()-tree->width()-200),widget->height()/6));
        FootVerticalLayout->addWidget( plotList.at(i));
    }
    tab->setLayout(FootVerticalLayout);
}


